const router = require('koa-router')()
const Mock = require('mockjs')

const { list } = Mock.mock({
  "list|1000": [{
    "id": "@id",
    "image": "@image(180x120, @color)",
    "title": "@ctitle",
    "sell|1-1000000": 1,
    "price|10-100": 1
  }]
})
router.get('/list', ctx => {
  const { pageCode = 1, pageSize = 10 } = ctx.request.query
  ctx.body = {
    code: 200,
    data: list.slice((pageCode - 1) * pageSize, pageCode * pageSize),
    message: 'ok'
  }
})

module.exports = router
